package com.kuaiditu.assistant.dagger.modules;


import com.kuaiditu.assistant.App;
import com.kuaiditu.assistant.api.yd_api.entity.DaoMaster;
import com.kuaiditu.assistant.api.yd_api.entity.DaoSession;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * Created by Eenie on 2017/5/5.
 * Email: eeniework@gmail.com
 * Des:提供数据库存储相关实例
 */
@Module
public class DBModule {

    public static final String DB_NAME = "assistant_db.db";

    @Provides
    @Singleton
    DaoMaster.DevOpenHelper provideDevOpenHelper(App context) {
        return new DaoMaster.DevOpenHelper(context, DB_NAME);
    }


    @Provides
    @Singleton
    DaoMaster provideDaoMaster(DaoMaster.DevOpenHelper helper) {
        return new DaoMaster(helper.getWritableDatabase());
    }


    @Provides
    @Singleton
    DaoSession provideDaoSession(DaoMaster master) {
        return master.newSession();
    }



}
